<?php

namespace common\models\metting;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use common\helpers\StringHelper;


class Metting extends \common\models\base\BaseModel
{
    /**
     * {@inheritdoc}
     * 绑定表
     */
    public static function tableName()
    {
        return '{{%by_metting}}';
    }

    /**
     *规则
     */
    public function rules()
    {
        return [
            [['title','content'],'required'],
            [['author','status','created_at','updated_at','people','place','date','type'],'safe'],
            [['people'], 'number'],
           // ['date', 'compare', 'compareValue' => date('Y-m-d',time()), 'operator' => '<='],
        ];
    }

    /**
     * @return array
     * 语言包
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'author' => '分享人',
            'date' => '会议时间',
            'people' => '参会人数',
            'place' => '会议地点',
            'type' => '类型',
            'content' => '内容',
            'status' => '状态',
            'created_at'=>'创建时间',
            'updated_at'=>'修改时间',
        ];
    }

    /**
     * @return array
     * 创建时间，修改时间自动存入数据库
     */
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::class,
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
                ],
            ],
        ];
    }
}